<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title>店铺宠物列表</title>

    <link href="./AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css"/>
    <link href="./AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css"/>

    <link href="./basic/css/demo.css" rel="stylesheet" type="text/css"/>

    <link href="./css/seastyle.css" rel="stylesheet" type="text/css"/>

    <script type="text/javascript" src="./basic/js/jquery-1.7.min.js"></script>
    <script type="text/javascript" src="./js/script.js"></script>

    <!--集成axios和vue-->
    <!--引入vue和axios-->
    <script src="js/plugins/vue/dist/vue.js"></script>
    <script src="js/plugins/axios/dist/axios.js"></script>
    <!--全局属性和基础路径-->
    <script src="js/common.js"></script>

</head>

<body>
	<div id="app">
		<!--顶部导航条 -->
		<div class="am-container header">
			<ul class="message-l">
				<div class="topMessage">
					<div class="menu-hd" v-if="logininfo"><!--loginForm不为null就显示下方内容-->
						{{logininfo.username}}
						<!--javascript:; - 点击的时候不跳转页面，而是去执行绑定的一段JavaScript代码-->
						<a href="javascript:;" @click="logout" style="color:red;">【退 出】</a>
					</div>
					<div class="menu-hd" v-else><!--否则显示该内容-->
						<a href="login.html" target="_top" class="h">亲，请登录</a>
						<a href="register.html">免费注册</a>
					</div>
				</div>
			</ul>
			<ul class="message-r">
				<div class="topMessage home">
					<div class="menu-hd"><a href="#" target="_top" class="h">商城首页</a></div>
				</div>
				<div class="topMessage my-shangcheng">
					<div class="menu-hd MyShangcheng"><a href="#" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a>
					</div>
				</div>
				<div class="topMessage mini-cart">
					<div class="menu-hd"><a id="mc-menu-hd" href="#" target="_top"><i
							class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum"
																								  class="h">0</strong></a>
					</div>
				</div>
				<div class="topMessage favorite">
					<div class="menu-hd"><a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a>
					</div>
			</ul>
		</div>

		<!--悬浮搜索框-->

		<div class="nav white">
			<div class="logo"><img src="./images/logo.png"/></div>
			<div class="logoBig">
				<li><img src="./images/logobig.png"/></li>
			</div>

			<div class="search-bar pr">
				<a name="index_none_header_sysc" href="#"></a>
				<form>
					<input id="searchInput" name="index_none_header_sysc" type="text" v-model="pageParams.keyword" placeholder="搜索" autocomplete="off">
					<input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="button" @click="keywordQuery">
				</form>
			</div>
		</div>

		<div class="clear"></div>
		<b class="line"></b>
		<div class="search">
			<div class="search-list">
				<div class="nav-table">
					<div class="long-title"><span class="all-goods">全部分类</span></div>
					<div class="nav-cont">
						<ul>
							<!--默认在当前窗口，不跳转新窗口
								就在当前宠物页面，不跳转不刷新，就# - 回到当前页面顶部
							-->
							<li class="index"><a href="index.html">首页</a></li>
							<li class="qc"><a href="pet.html" target="_blank">宠物</a></li>
							<li class="qc"><a href="product.html" target="_blank">服务</a></li>
							<li class="qc"><a href="#">宠物百科</a></li>
							<li class="qc last"><a href="aboutUs.html" target="_blank">关于我们</a></li>
						</ul>
						<div class="nav-extra" @click="goPublish">
							<i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>发布寻主消息
							<i class="am-icon-angle-right" style="padding-left: 10px;"></i>
						</div>
					</div>
				</div>


				<div class="am-g am-g-fixed">
					<div class="am-u-sm-12 am-u-md-12">
						<div class="theme-popover">
							<div class="searchAbout">
								<span class="font-pale">相关搜索：</span>
								<a title="坚果" href="#">坚果</a>
								<a title="瓜子" href="#">瓜子</a>
								<a title="鸡腿" href="#">豆干</a>

							</div>
							<ul class="select">
								<p class="title font-normal">
									<span class="fl">松子</span>
									<span class="total fl">搜索到<strong class="num">997</strong>件相关商品</span>
								</p>
								<div class="clear"></div>
								<li class="select-result">
									<dl>
										<dt>已选</dt>
										<dd class="select-no"></dd>
										<p class="eliminateCriteria">清除</p>
									</dl>
								</li>
								<div class="clear"></div>
								<li class="select-list">
									<dl id="select1">
										<dt class="am-badge am-round">品牌</dt>

										<div class="dd-conent">
											<dd class="select-all selected"><a href="#">全部</a></dd>
											<dd><a href="#">百草味</a></dd>
											<dd><a href="#">良品铺子</a></dd>
											<dd><a href="#">新农哥</a></dd>
											<dd><a href="#">楼兰蜜语</a></dd>
											<dd><a href="#">口水娃</a></dd>
											<dd><a href="#">考拉兄弟</a></dd>
										</div>

									</dl>
								</li>
								<li class="select-list">
									<dl id="select2">
										<dt class="am-badge am-round">种类</dt>
										<div class="dd-conent">
											<dd class="select-all selected"><a href="#">全部</a></dd>
											<dd><a href="#">东北松子</a></dd>
											<dd><a href="#">巴西松子</a></dd>
											<dd><a href="#">夏威夷果</a></dd>
											<dd><a href="#">松子</a></dd>
										</div>
									</dl>
								</li>
								<li class="select-list">
									<dl id="select3">
										<dt class="am-badge am-round">选购热点</dt>
										<div class="dd-conent">
											<dd class="select-all selected"><a href="#">全部</a></dd>
											<dd><a href="#">手剥松子</a></dd>
											<dd><a href="#">薄壳松子</a></dd>
											<dd><a href="#">进口零食</a></dd>
											<dd><a href="#">有机零食</a></dd>
										</div>
									</dl>
								</li>

							</ul>
							<div class="clear"></div>
						</div>
						<div class="search-content">
							<div class="sort">
								<li class="first"><a title="综合">综合排序</a></li>
								<li><a title="销量">销量排序</a></li>
								<li><a title="价格">价格优先</a></li>
								<li class="big"><a title="评价" href="#">评价为主</a></li>
							</div>
							<div class="clear"></div>

							<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes">
								<li v-for="pet in pets" @click="goPetDetail(pet.id)">
									<div class="i-pic limit">
										<!--外面用双引号，里面就用单引号
											"imgPrefix+pet.resources.split(',')[0]" - 前缀+图片上传的存储路径【多张图只取第一个[0]】
										-->
										<img :src="imgPrefix+pet.resources.split(',')[0]"/>
										<p class="title fl">【{{pet.shop?pet.shop.name:''}}】{{pet.name}}</p>
										<p class="price fl">
											<b>¥</b>
											<strong>{{pet.saleprice}}</strong>
										</p>
										<!--<p class="number fl">
											销量<span>1110</span>
										</p>-->
									</div>
								</li>
							</ul>
						</div>
						<div class="search-side">

							<div class="side-title">
								经典搭配
							</div>

							<li>
								<div class="i-pic check">
									<img src="./images/cp.jpg"/>
									<p class="check-title">萨拉米 1+1小鸡腿</p>
									<p class="price fl">
										<b>¥</b>
										<strong>29.90</strong>
									</p>
									<p class="number fl">
										销量<span>1110</span>
									</p>
								</div>
							</li>
							<li>
								<div class="i-pic check">
									<img src="./images/cp2.jpg"/>
									<p class="check-title">ZEK 原味海苔</p>
									<p class="price fl">
										<b>¥</b>
										<strong>8.90</strong>
									</p>
									<p class="number fl">
										销量<span>1110</span>
									</p>
								</div>
							</li>
							<li>
								<div class="i-pic check">
									<img src="./images/cp.jpg"/>
									<p class="check-title">萨拉米 1+1小鸡腿</p>
									<p class="price fl">
										<b>¥</b>
										<strong>29.90</strong>
									</p>
									<p class="number fl">
										销量<span>1110</span>
									</p>
								</div>
							</li>

						</div>
						<div class="clear"></div>
						<!--
							class="am-disabled" - 禁用当前按钮
							class="am-active" - 当前页，显示所处的li标签的背景颜色
								问题：
								  	遍历：显示页码
										1-5页数【用到向上取整函数】：Math.ceil(totals/pageSize) = totalPage总页数【在js两个数相除，是有小数部分的】  用v-for
									添加样式：
										1. 当前页是第一页的时候，要禁用上一页&laquo;
										2. 当前页是最后一页totalPage，要禁用下一页&raquo;
										3. 如果遍历的页码就是当前页，添加[am-active]这个样式
									添加单击事件：
										上一页，页码要添加；下一页也要添加
								注意：属性绑定：不用this，直接用模型数据的名字即可
								javascript:; - 不要跳转页面，而是去执行一段js代码
						-->
						<!--分页 -->
						<ul class="am-pagination am-pagination-right">
							<li :class="pageParams.currentPage==1?'am-disabled':''">
								<a href="javascript:;" @click="prePage">&laquo;</a>
							</li>
							<li v-for="num in totalPage" :class="pageParams.currentPage==num?'am-active':''">
								<a href="javascript:;" @click="goPage(num)">{{num}}</a>
							</li>
							<li :class="pageParams.currentPage==totalPage?'am-disabled':''">
								<a href="javascript:;" @click="nextPage">&raquo;</a>
							</li>
						</ul>

					</div>
				</div>
				<div class="footer">
					<div class="footer-hd">
						<p>
							<a href="#">恒望科技</a>
							<b>|</b>
							<a href="#">商城首页</a>
							<b>|</b>
							<a href="#">支付宝</a>
							<b>|</b>
							<a href="#">物流</a>
						</p>
					</div>
					<div class="footer-bd">
						<p>
							<a href="#">关于恒望</a>
							<a href="#">合作伙伴</a>
							<a href="#">联系我们</a>
							<a href="#">网站地图</a>
							<em>© 2015-2025 Hengwang.com 版权所有. 更多模板 <a href="http://www.cssmoban.com/" target="_blank"
																	   title="模板之家">模板之家</a> - Collect from <a
									href="http://www.cssmoban.com/" title="网页模板" target="_blank">网页模板</a></em>
						</p>
					</div>
				</div>
			</div>

		</div>

		<!--引导 -->
		<div class="navCir">
			<li><a href="home2.html"><i class="am-icon-home "></i>首页</a></li>
			<li><a href="sort.html"><i class="am-icon-list"></i>分类</a></li>
			<li><a href="shopcart.html"><i class="am-icon-shopping-basket"></i>购物车</a></li>
			<li><a href="./person/index.html"><i class="am-icon-user"></i>我的</a></li>
		</div>

		<!--菜单 -->
		<div class=tip>
			<div id="sidebar">
				<div id="wrap">
					<div id="prof" class="item">
						<a href="#">
							<span class="setting"></span>
						</a>
						<div class="ibar_login_box status_login">
							<div class="avatar_box">
								<p class="avatar_imgbox"><img src="./images/no-img_mid_.jpg"/></p>
								<ul class="user_info">
									<li>用户名：sl1903</li>
									<li>级&nbsp;别：普通会员</li>
								</ul>
							</div>
							<div class="login_btnbox">
								<a href="#" class="login_order">我的订单</a>
								<a href="#" class="login_favorite">我的收藏</a>
							</div>
							<i class="icon_arrow_white"></i>
						</div>

					</div>
					<div id="shopCart" class="item">
						<a href="#">
							<span class="message"></span>
						</a>
						<p>
							购物车
						</p>
						<p class="cart_num">0</p>
					</div>
					<div id="asset" class="item">
						<a href="#">
							<span class="view"></span>
						</a>
						<div class="mp_tooltip">
							我的资产
							<i class="icon_arrow_right_black"></i>
						</div>
					</div>

					<div id="foot" class="item">
						<a href="#">
							<span class="zuji"></span>
						</a>
						<div class="mp_tooltip">
							我的足迹
							<i class="icon_arrow_right_black"></i>
						</div>
					</div>

					<div id="brand" class="item">
						<a href="#">
							<span class="wdsc"><img src="./images/wdsc.png"/></span>
						</a>
						<div class="mp_tooltip">
							我的收藏
							<i class="icon_arrow_right_black"></i>
						</div>
					</div>

					<div id="broadcast" class="item">
						<a href="#">
							<span class="chongzhi"><img src="./images/chongzhi.png"/></span>
						</a>
						<div class="mp_tooltip">
							我要充值
							<i class="icon_arrow_right_black"></i>
						</div>
					</div>

					<div class="quick_toggle">
						<li class="qtitem">
							<a href="#"><span class="kfzx"></span></a>
							<div class="mp_tooltip">客服中心<i class="icon_arrow_right_black"></i></div>
						</li>
						<!--二维码 -->
						<li class="qtitem">
							<a href="#none"><span class="mpbtn_qrcode"></span></a>
							<div class="mp_qrcode" style="display:none;"><img src="./images/weixin_code_145.png"/><i
									class="icon_arrow_white"></i></div>
						</li>
						<li class="qtitem">
							<a href="#top" class="return_top"><span class="top"></span></a>
						</li>
					</div>

					<!--回到顶部 -->
					<div id="quick_links_pop" class="quick_links_pop hide"></div>

				</div>

			</div>
			<div id="prof-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					我
				</div>
			</div>
			<div id="shopCart-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					购物车
				</div>
			</div>
			<div id="asset-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					资产
				</div>

				<div class="ia-head-list">
					<a href="#" target="_blank" class="pl">
						<div class="num">0</div>
						<div class="text">优惠券</div>
					</a>
					<a href="#" target="_blank" class="pl">
						<div class="num">0</div>
						<div class="text">红包</div>
					</a>
					<a href="#" target="_blank" class="pl money">
						<div class="num">￥0</div>
						<div class="text">余额</div>
					</a>
				</div>

			</div>
			<div id="foot-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					足迹
				</div>
			</div>
			<div id="brand-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					收藏
				</div>
			</div>
			<div id="broadcast-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					充值
				</div>
			</div>
		</div>
	</div>
	<script>
		window.jQuery || document.write('<script src="basic/js/jquery-1.9.min.js"><\/script>');
	</script>
	<script type="text/javascript" src="./basic/js/quick_links.js"></script>
	<div class="theme-popover-mask"></div>
	<script type="text/javascript">
		new Vue({
			el:'#app',//挂载在id上，用id选择器 - #id值
			data:{
				//分页参数 - 会赋值给后端的查询工具类相应名字的字段
				pageParams:{
					currentPage:1,	//默认当前页为第一页
					pageSize:12,	//每页显示条数
					state:1,		//上架的宠物
					keyword:'',		//关键字查询
					shopId:null,	//店铺id - 用于查询所有符合该店铺的宠物 - 只查询该店铺中所有宠物
				},
				//所有宠物的数组，用于前台页面展示
				pets:[],
				//图片前缀
				imgPrefix:"http://123.207.27.208",
				totals:0, 	//总数量 - 计算分页栏的信息

				logininfo:null, 	//登录信息对象
			},
			methods:{
				getPets(){
					this.$http.post("/pet",this.pageParams).then(res=>{	//res这个返回值里面有data 和totals - 来自工具类pageList中的字段参数
							this.pets = res.data.data;
							this.totals = res.data.totals;
					})
				},

				//获取当前店铺的所有宠物
				getCompanyPets(){
					//和获取所有宠物用的同一个分页高级查询的接口，通过动态sql限制shop_id而已
					this.$http.post("/pet",this.pageParams).then(res=>{
						this.pets = res.data.data;
						this.totals = res.data.totals;
					})
				},

				//点击上一页
				prePage(){//第一页这个按钮是禁用的
					//因为第一页的时候禁用了 - 不会调用该方法，所以就不用判断了
					this.pageParams.currentPage--;
					this.getPets();//发请求获取当前页展示的数据
				},

				//点击下一页
				nextPage(){//同理
					//能到这个方法绝对不是禁用的
					this.pageParams.currentPage++;
					this.getPets();//发请求获取当前页展示的数据
				},

				//跳转到所点击页
				goPage(num){
					this.pageParams.currentPage = num;//先设置，再调用方法
					this.getPets();
				},
				//关键字查询=高级查询
				keywordQuery(){
					this.pageParams.currentPage = 1;
					this.getPets();
				},
				//退出功能
				logout(){
					//移除存储在localStorage中的登录信息
					localStorage.removeItem("token");//传key值
					localStorage.removeItem("logininfo");
					location.href = "/login.html";
				},
				//跳转到详情页面
				goPetDetail(id){
					//跳转到新窗口 - 详情页面
					window.open("/petDetail.html?id="+id);
				},
				//跳转到寻主消息页面
				goPublish(){
					window.open("/publish.html")
				}
			},
			//用于计算属性的【可以计算多个属性】 - 这里用来计算页码 - 调用计算属性里面的方法时候不用加() - 当模型数据属性一样用
			//计算属性的好处：调用的时候直接用属性的名字，例如：totalPage 【不用加()】
			computed:{
				totalPage(){
				return Math.ceil(this.totals/this.pageParams.pageSize);//计算总页数 = 最后一页的页数
				},
			},
			mounted(){//钩子函数之一 - 页面加载函数
				//要获取到店铺id - 再调用店铺所有宠物的方法 - 这样店铺id才会跟着走，传给后端
				//从地址栏获取到店铺id
				this.pageParams.shopId = parseUrlParams2Obj(location.href).id;
				this.getCompanyPets();

				//显示登录的用户的信息
				let logininfo =  localStorage.getItem("logininfo");//从本地存储拿到logininfo的值
				if (logininfo){//logininfo如果有，就直接赋值给页面中双向绑定的数据logininfo【MVVM】
					//转化成对象，可以获取对象中的属性
					this.logininfo = JSON.parse(logininfo);//如果logininfo有值，就将该JSON字符串转化成JSON对象，赋给data数据模型【双向绑定了的】

				}
			}
		})
	</script>
</body>

</html>